<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *员工管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$tabs=array(
	array('op'=>'list','title'=>'待支付列表'),
	array('op'=>'ok','title'=>'已支付列表'),	
	array('op'=>'no','title'=>'支付失败列表'),	
);
if($_RQ['op']=='list'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	$params['ispay']=0;
	if(!empty($_RQ['title'])){
		$pid=pdo_getcolumn('jy_zhongchou_project',array('uniacid'=>$_SESSION['uniacid'],'title like %'=>$_RQ['title'].'%'),'id');
		$params['pid']=intval($_RQ['pid']);
		$return['params']['pid']=$_RQ['pid'];
	}
	if(!empty($_RQ['nickname'])){
		$mid=pdo_getcolumn('jy_zhongchou_member',array('uniacid'=>$_SESSION['uniacid'],'nickname like %'=>$_RQ['nickname'].'%'),'mid');
		$params['mid']=$mid;
		$return['params']['mid']=$mid;
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','uniacid','ordersn','pid','ispay','mid','msg','fee','status','ispay','shouxufei','status','createtime','successtime');
	$list=pdo_getslice('jy_zhongchou_paylog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$project=pdo_get('jy_zhongchou_project',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['pid']));
			$member=pdo_get('jy_zhongchou_member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$item['mid']));
			$user=pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['mid']));
			
			$item['title']=$project['title'];
			$item['nickname']=$user['nickname'];
			$item['avatar']=$user['avatar'];
			
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>true,'list'=>array(
			array('name'=>'ordersn','title'=>'订单编号','type'=>'string'),
			array('name'=>'title','title'=>'项目名称','type'=>'string'),
			array('name'=>'nickname','title'=>'支持人昵称','type'=>'string'),
			array('name'=>'avatar','title'=>'头像','type'=>'image'),
			array('name'=>'fee','title'=>'金额','type'=>'string'),
			array('name'=>'msg','title'=>'留言','type'=>'string'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
			
		)),
		'search'=>array(
			array('name'=>'title','width'=>15,'title'=>'项目名称','type'=>'string'),
			array('name'=>'nickname','width'=>15,'title'=>'支持人昵称','type'=>'string'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='ok'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	$params['ispay']=1;
	if(!empty($_RQ['title'])){
		$pid=pdo_getcolumn('jy_zhongchou_project',array('uniacid'=>$_SESSION['uniacid'],'title like %'=>$_RQ['title'].'%'),'id');
		$params['pid']=intval($_RQ['pid']);
		$return['params']['pid']=$_RQ['pid'];
	}
	if(!empty($_RQ['nickname'])){
		$mid=pdo_getcolumn('jy_zhongchou_member',array('uniacid'=>$_SESSION['uniacid'],'nickname like %'=>$_RQ['nickname'].'%'),'mid');
		$params['mid']=$mid;
		$return['params']['mid']=$mid;
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','uniacid','ordersn','pid','ispay','mid','fee','msg','status','ispay','shouxufei','status','createtime','successtime');
	$list=pdo_getslice('jy_zhongchou_paylog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$project=pdo_get('jy_zhongchou_project',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['pid']));
			$member=pdo_get('jy_zhongchou_member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$item['mid']));
			$user=pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['mid']));
			$item['title']=$project['title'];
			$item['nickname']=$user['nickname'];
			$item['avatar']=$user['avatar'];
			
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>true,'list'=>array(
			array('name'=>'ordersn','title'=>'订单编号','type'=>'string'),
			array('name'=>'title','title'=>'项目名称','type'=>'string'),
			array('name'=>'nickname','title'=>'支持人昵称','type'=>'string'),
			array('name'=>'avatar','title'=>'头像','type'=>'image'),
			array('name'=>'fee','title'=>'金额','type'=>'string'),
			array('name'=>'msg','title'=>'留言','type'=>'string'),
			array('name'=>'successtime','title'=>'完成支付时间','type'=>'time'),
			
		)),
		'search'=>array(
			array('name'=>'title','width'=>15,'title'=>'项目名称','type'=>'string'),
			array('name'=>'nickname','width'=>15,'title'=>'支持人昵称','type'=>'string'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='no'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	$params['ispay']=-1;
	if(!empty($_RQ['title'])){
		$pid=pdo_getcolumn('jy_zhongchou_project',array('uniacid'=>$_SESSION['uniacid'],'title like %'=>$_RQ['title'].'%'),'id');
		$params['pid']=intval($_RQ['pid']);
		$return['params']['pid']=$_RQ['pid'];
	}
	if(!empty($_RQ['nickname'])){
		$mid=pdo_getcolumn('jy_zhongchou_member',array('uniacid'=>$_SESSION['uniacid'],'nickname like %'=>$_RQ['nickname'].'%'),'mid');
		$params['mid']=$mid;
		$return['params']['mid']=$mid;
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','uniacid','ordersn','pid','ispay','mid','fee','msg','status','ispay','shouxufei','status','createtime','successtime');
	$list=pdo_getslice('jy_zhongchou_paylog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$project=pdo_get('jy_zhongchou_project',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['pid']));
			$member=pdo_get('jy_zhongchou_member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$item['mid']));
			$user=pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['mid']));
			
			$item['title']=$project['title'];
			$item['nickname']=$user['nickname'];
			$item['avatar']=$user['avatar'];
			
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>true,'list'=>array(
			array('name'=>'ordersn','title'=>'订单编号','type'=>'string'),
			array('name'=>'title','title'=>'项目名称','type'=>'string'),
			array('name'=>'nickname','title'=>'支持人昵称','type'=>'string'),
			array('name'=>'avatar','title'=>'头像','type'=>'image'),
			array('name'=>'fee','title'=>'金额','type'=>'string'),
			array('name'=>'msg','title'=>'留言','type'=>'string'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
			
		)),
		'search'=>array(
			array('name'=>'title','width'=>15,'title'=>'项目名称','type'=>'string'),
			array('name'=>'nickname','width'=>15,'title'=>'支持人昵称','type'=>'string'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}

if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_zhongchou_paylog',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}
